#pragma once
#include <string>
#include "Token.h"

class Rule{

public:
	Rule();
	virtual ~Rule();
	Rule(const Rule& rule);
	const Rule& operator=(const Rule& rule);

	// init() is where any mem. allocation should be preformed for the Rule life-time and the initFlag set to True
	virtual bool init()=0;

	// destroy is where clean-ups should be preformed for the Rule.
	virtual void destroy()=0;

	/* checkRule is a pure abstract member function
	 * for every rule that somebody wants to check
	 * he extends this class and provides an implementation.
	 *
	 * checkRule gets a Token parameter to check and keeps an internal state for the validity of the rule
	 * checkRule returns a string representation of an error if one was found.
	 * checkRule must never fail - no exceptions throwin is allowed and any memorey allocations should be preformed at init()!!.
	 */
	virtual std::string checkRule(Token& token);

protected:
	virtual std::string ruleCheckImpl(Token& token)=0;

private:
	bool initFlag;
};